package com.sskj.jkzx.service.impl.yc;

import javax.transaction.Transactional;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sskj.jkzx.domain.entity.quantity.YCAlertQuantity;
import com.sskj.jkzx.domain.entity.quantity.YCQuantityTemporary;
import com.sskj.jkzx.repository.yc.YCAlertQuantityRepository;
import com.sskj.jkzx.repository.yc.YCQuantityTemporaryRepository;

/**
 * 扬尘数据增删改查服务
 * 
 * @author chenliang
 *
 */
@Service
public class YCCURDServiceImpl {

	protected final Log logger = LogFactory.getLog(YCCURDServiceImpl.class);

	@Autowired
	YCAlertQuantityRepository ycAlertQuantityRepository;

	@Autowired
	YCQuantityTemporaryRepository ycQuantityTemporaryRepository;

	@Transactional
	public void saveAlertQuantity(YCAlertQuantity entity) {
		logger.info(entity.toString());
		ycAlertQuantityRepository.save(entity);
	}

	public YCAlertQuantity getAlertQuantity() {
		return ycAlertQuantityRepository.findLastOne();
	}

	public int getEngCount() {
		YCQuantityTemporary entity = ycQuantityTemporaryRepository.get();
		return entity.getEngCount();
	}

	public int getEquipmentCount() {
		YCQuantityTemporary entity = ycQuantityTemporaryRepository.get();
		return entity.getEquipmentCount();
	}

	public int getRedAlertCount() {
		YCQuantityTemporary entity = ycQuantityTemporaryRepository.get();
		return entity.getRedAlertCount();
	}

	public int getYellowAlertCount() {
		YCQuantityTemporary entity = ycQuantityTemporaryRepository.get();
		return entity.getYellowAlertCount();
	}

}
